package GUI;

import java.util.ArrayList;

import javax.swing.JButton;

import Algorithms.Context;
import Algorithms.IDepthStrategy;
import Joc.Joc;
import Joc.JocStates;
import Operators.FarmerOperators;
import Operators.WaterCupOperators;
import States.FarmerStates;
import States.WaterCupState;
import Templates.Operator;
import Templates.State;

public class AdancimeIterativaCommand extends JButton implements Command{

	private static final long serialVersionUID = 1L;
	
	public AdancimeIterativaCommand(){
		super("Algoritm Adancime Iterativa");
	}
	
	public void execute(){
		SimulareDesenPanel.clearDesen();
		Joc j=Joc.getJocinstance();
		if (j.getState() == JocStates.CANI) {
			ArrayList<Operator<WaterCupState>> waterCupOperators=WaterCupOperators.returnOperators();
			State<WaterCupState> waterCupInitialState=WaterCupState.initalState();
			ArrayList<State<WaterCupState>> waterCupFinalState=WaterCupState.finalStates();
			String WaterCupIDepth="WaterCupIDepth.txt";
			Context<WaterCupState> w=new Context<WaterCupState>(new IDepthStrategy<WaterCupState>());
			w.setStrategy(new IDepthStrategy<WaterCupState>());
			w.executeStrategy(waterCupInitialState,waterCupFinalState,waterCupOperators,WaterCupIDepth);
			MassagePanel.writeMessagePanel("S-a aplicat algoritmul Adancime Iterativa!" );
		}
		else if(j.getState()==JocStates.LCV){
			ArrayList<Operator<FarmerStates>> farmerOperators=FarmerOperators.returnOperators();
			State<FarmerStates> FarmerInitialState=FarmerStates.initalState();
			ArrayList<State<FarmerStates>> FarmerFinalState=FarmerStates.finalStates();
			String FarmerIDepth="FarmerIDepth.txt";
			Context<FarmerStates> f=new Context<FarmerStates>(new IDepthStrategy<FarmerStates>());
			f.executeStrategy(FarmerInitialState,FarmerFinalState,farmerOperators,FarmerIDepth);
			MassagePanel.writeMessagePanel("S-a aplicat algoritmul Adancime Iterativa!" );
		}
		else if (j.getState() == JocStates.PUZZLE) {
			MassagePanel.writeMessagePanel("NU poate fi aplicat algoritmul Adancime Iterativa!" );
		}
		
	}

}
